package basis

/**
 *   基础数据类型
 *   @project kotlin-docs
 *   @datetime 2020/9/27 14:02
 *
 */
fun main() {
    val oneByte: Byte = 1
    // 未超出Int最大值的默认Int 超出为Long
    val one = 2
    val threeBillion = 30000000000
    // 显示指定Long
    val oneLong: Long = 1L

    val oneDouble = 1.1
    println(oneDouble)
    println(oneDouble / one)

    println(oneDouble.toInt())

    val a = 3.555555555555
    println(a)
    println(a.toInt())

    val asc = Array(5) {1}
    asc.forEach { println(it) }
    val asc1 = Array(5){i -> i+10}
    asc1.forEach { t -> println(t) }

    val x: IntArray = intArrayOf(1, 2, 3)
    x.forEach { println(it) }
    val arr = IntArray(5)
    arr.forEach { println(it) }

    stringDemo()


}

fun stringDemo() {
    val text = """
        >hello!
        >  world!
    """
    println(text)
    println(text.trimIndent())
    println(text.trimMargin())
    println(text.trimMargin(">"))

    // 字符串模板
    val s = "abc"
    println("s = $s")
    println("s = $ s")
    println("s = ${s.length}")
}